package leetcode.top100;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/12/22 5:56 PM
 * @description：
 */
public class _055_跳跃游戏 {
    @Test
    public void test() {
        System.out.println(new Solution().canJump(new int[]{0, 1}));
    }

    class Solution {
        public boolean canJump(int[] nums) {
            int n = nums.length;
            if (n == 0) return true;
            int maxRight = nums[0];
            for (int i = 1; i <= maxRight && i < n; i++) {
                maxRight = Math.max(maxRight, i + nums[i]);
            }
            return maxRight >= n - 1;
        }
    }
}
